The functional paradigm shifts the developer's mental model from "updating a stateful box" to applying mathematical transformations to immutable values. In Elixir, data is never changed; it is only reborn into new forms.
1. The Mathematical Assertion
When you write $x = a + 1$, you are not assigning a result to a variable. Instead, you are simply asserting that the expressions $x$ and $a + 1$ have the same value. This mirrors algebraic logic where $x$ represents a fixed value in a specific context.
2. Immutability as a Guarantee
In Elixir, all values are immutable. Data cannot be altered once created. This eliminates "side effects" where a function might unexpectedly change a global variable or a passed-in object, ensuring that code is predictable and thread-safe.
3. Transformation vs. Mutation
We never modify data in place. Elixir doesn't have assignment; instead, it tries to match values to patterns. To "change" a value, we pass the original data through a function to produce a completely new version.
"elixir"
iex> cap_name = String.capitalize name
"Elixir"
iex> name
"elixir" (Still pristine!)